package com.ctg.itrdc.mainframe.control;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ctg.itrdc.sysmgr.permission.core.CtgUser;
import com.ctg.itrdc.sysmgr.permission.core.IPermissionService;
import com.ctg.itrdc.sysmgr.permission.core.control.CommonResult;
import com.ctg.itrdc.sysmgr.permission.core.utils.WebUtils;
@Controller
@RequestMapping("/permission")
public class SystemPermissionController {
	@Resource
	private IPermissionService permissionService;
	
	@RequestMapping("/menu_tree")
	@ResponseBody
	public CommonResult selectMenuTree() {
		CtgUser ctgUser = WebUtils.getCtgUser();
		Long sysUserId = ctgUser.getSysUserId();
		Long sysPostId = ctgUser.getSysPostId();
		List<Map<String, Object>> menuTree = permissionService.selectMenuTree(sysUserId, sysPostId);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("menus", menuTree);
		map.put("user", ctgUser);
		return new CommonResult(HttpStatus.OK.toString(), "", map);
	}
}
